﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HPPClientLibrary.XmlableObject
{
    using System.Xml.Linq;

    public class FilesList:List<File>,IXmlable
    {
        public virtual XDocument ToXml()
        {
            XDocument xdoc = new XDocument();
            xdoc.Declaration = new XDeclaration("1.0", "utf-8", "yes");
            XElement files = new XElement("Files");
            foreach (File file in this)
            {
                files.Add(new XElement("File", new XAttribute("FileName", file.FileName), new XAttribute("Hash", file.Hash)));
            }
            xdoc.Add(files);
            return xdoc;           
        }
        public void AddFile(File file)
        {
            Add(file);
        }
        public bool RemoveFile(File file)
        {
            if (Remove(file))
            {
                return true;
            }
            return false;
        }

    }

}
